package org.ace.nettyhandler;


import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;

import org.ace.endingCode.AMF3NettyDecoder;
import org.ace.endingCode.AMF3NettyEncoder;
import org.ace.endingCode.LengthFieldDecoder;
import org.ace.endingCode.LengthFieldEncoder;


public abstract class HexDumpProxyPipelineFactory extends
		ChannelInitializer<SocketChannel> {
	
	protected void initChannel(SocketChannel ch) throws Exception{
		ChannelPipeline pipeline=ch.pipeline();
		pipeline.addLast("frameDecoder", new LengthFieldDecoder());
		pipeline.addLast("frameEncoder", new LengthFieldEncoder());
		
		pipeline.addLast("encoder", new AMF3NettyEncoder());
		pipeline.addLast("decoder", new AMF3NettyDecoder());


		pipeline.addLast("handler", createHexDumpProxyHandler());
	}

//	@Override
//	public ChannelPipeline getPipeline() throws Exception {
//		ChannelPipeline pipeline = Channels.pipeline(); // Note the static import.
//
//		pipeline.addLast("lengthFieldDecoder", new LengthFieldDecoder());
//		pipeline.addLast("lengthFieldEncoder", new LengthFieldEncoder());
//		
//		pipeline.addLast("encoder", new AMF3NettyEncoder());
//		pipeline.addLast("decoder", new AMF3NettyDecoder());
//
//
//		pipeline.addLast("handler", createHexDumpProxyHandler());
//
//		return pipeline;
//	}
//
	public abstract ChannelHandler createHexDumpProxyHandler();

}
